package br.edu.ufcg.dsc.domain.resource;

import br.edu.ufcg.dsc.domain.marc.MARCResource;

public class Issue {

	private String cutter, title, creator, contributor, publisherName, source, date, ISBN, cduClassification,
				   publisherLocal, languageName, country;
	
	public Issue(MARCResource marc){
		setTitle(getAttribute(marc, "245", "a"));
		setCreator(getAttribute(marc, "720", "a"));
		setContributor(getAttribute(marc, "720", "a"));
		setSource(getAttribute(marc, "786", "a"));
		setDate(getAttribute(marc, "260", "c"));
		setPublisherName(getAttribute(marc, "260", "b"));
		//nao encontrei.
		setCutter(getAttribute(marc, "XXX", "X"));
		setISBN(getAttribute(marc, "XXX", "X"));
		setCduClassification(getAttribute(marc, "XXX", "X"));
		setPublisherLocal(getAttribute(marc, "XXX", "X"));
		setLanguageName(getAttribute(marc, "XXX", "X"));
		setCountry(getAttribute(marc, "XXX", "X"));
	}
	
	public Issue(){}
	
	private String getAttribute(MARCResource marc, String field, String subfield) {
		for (String key : marc.getDataFields().get(field).getSubfields().keySet())
			if (key.startsWith(subfield))
				return marc.getDataFields().get(field).getSubfields().get(key);

		return "";
	}

	public String getISBN() {
		return ISBN;
	}

	public void setISBN(String ISBN) {
		this.ISBN = ISBN;
	}

	public String getCduClassification() {
		return cduClassification;
	}

	public void setCduClassification(String cduClassification) {
		this.cduClassification = cduClassification;
	}

	public String getPublisherLocal() {
		return publisherLocal;
	}

	public void setPublisherLocal(String publisherLocal) {
		this.publisherLocal = publisherLocal;
	}

	public String getLanguageName() {
		return languageName;
	}

	public void setLanguageName(String languageName) {
		this.languageName = languageName;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getCutter() {
		return cutter;
	}


	public void setCutter(String cutter) {
		this.cutter = cutter;
	}


	public String getTitle() {
		return title;
	}


	public void setTitle(String title) {
		this.title = title;
	}


	public String getCreator() {
		return creator;
	}


	public void setCreator(String creator) {
		this.creator = creator;
	}


	public String getContributor() {
		return contributor;
	}


	public void setContributor(String contributor) {
		this.contributor = contributor;
	}


	public String getPublisherName() {
		return publisherName;
	}


	public void setPublisherName(String publisherName) {
		this.publisherName = publisherName;
	}


	public String getSource() {
		return source;
	}


	public void setSource(String source) {
		this.source = source;
	}


	public String getDate() {
		return date;
	}


	public void setDate(String date) {
		this.date = date;
	}
	
}
